<!DOCTYPE html>
<html>
<head>
<title>代码生成器</title>
<#include "/header.html">
<link rel="stylesheet" href="${request.contextPath}/statics/css/manager.css">
</head>
<div id="rrapp">
	<div class="grid_container">
		<div class="grid_count">书格1</div>
		<div id="div1_1" class="open1">
        	<div id="div2_1" class="open2"></div>
    	</div>
    </div>
	<div class="grid_container">
		<div class="grid_count">书格5</div>
	    <div id="div1_5" class="open1">
	        <div id="div2_5" class="open2"></div>
	    </div>
    </div>
	<br/>
    <div class="grid_container">
		<div class="grid_count">书格2</div>
    	<div id="div1_2" class="open1">
        	<div id="div2_2" class="open2"></div>
    	</div>
	</div>
	<div class="grid_container">
	    <div class="grid_count">书格6</div>
	    <div id="div1_6" class="open1">
	        <div id="div2_6" class="open2"></div>
	    </div>
    </div>
    <br/>
    <div class="grid_container"> 
	    <div class="grid_count">书格3</div>
	    <div id="div1_3" class="open1">
	        <div id="div2_3" class="open2"></div>
	    </div>
    </div>  
    <div class="grid_container">
	    <div class="grid_count">书格7</div>
	    <div id="div1_7" class="open1">
	        <div id="div2_7" class="open2"></div>
	    </div>
    </div>
    <br>
     <div class="grid_container">
	    <div class="grid_count">书格4</div>
	    <div id="div1_4" class="open1">
	        <div id="div2_4" class="open2"></div>
	    </div>
    </div>
    <div class="grid_container">
	    <div class="grid_count">书格8</div>
	    <div id="div1_8" class="open1">
	        <div id="div2_8" class="open2"></div>
	    </div>
    </div>
    <br/>
    <label>提示：</label> 
    <textarea id="hint" name="DIVCSS5" cols="30" rows="5"> </textarea> 
</div>
<script type="text/javascript" src="${request.contextPath}/statics/js/modules/operation/book-shelf-open.js?_${.now?long}"></script>
<script type="text/javascript">
var gridCode = GetQueryString("code");
var data = {"code":gridCode};
$.ajax({
	url : baseURL + "operation/bookShelf/bookgrids",
	type : 'POST',
	contentType : "application/json; charset=utf-8",
	data : JSON.stringify(data),
	dataType : 'json',
	success : function(result) {
		if (result.detail != null) {
			for(var i=0;i<result.detail.length;i++){
					console.log(result.detail[i]);
				if(result.detail[i].lockStatus==2||result.detail[i].lockStatus==3||result.detail[i].lockStatus==5){
					var postfix = result.detail[i].bookgridCode.substr(10,2).replace(/\b(0+)/gi,"");
					var div1_obj = document.getElementById("div1_"+postfix);
					var div2_obj = document.getElementById("div2_"+postfix);
					div1_obj.setAttribute("class", "close1");
					div2_obj.setAttribute("class", "close2");
				}else{
					var postfix = result.detail[i].bookgridCode.substr(10,2).replace(/\b(0+)/gi,"");
					var div1_obj = document.getElementById("div1_"+postfix);
					var div2_obj = document.getElementById("div2_"+postfix);
					div1_obj.setAttribute("class", "open1");
					div2_obj.setAttribute("class", "open2");
				}
			}
		} else {
			layer.msg(message, {
				icon : -1
			});
		}
	}
});
var returnMessage = '';
window.onload=function(){
	var codePostfix = GetQueryString("code");
    var div2_1=document.getElementById("div2_1");
    var div1_1=document.getElementById("div1_1");
    div2_1.onclick=function(){
    	if(div2_1.className=='close2'){
	    	div1_1.className=(div1_1.className=="close1")?"open1":"close1";
	      	div2_1.className=(div2_1.className=="close2")?"open2":"close2";
	      	var jsonData = {"bookgridCode":codePostfix+"01"};
	     	unlock('operation/bookShelf/unlock',jsonData,'开柜成功','01');
    	}
    }
    
    
    var div2_2=document.getElementById("div2_2");
    var div1_2=document.getElementById("div1_2");
    div2_2.onclick=function(){
    	if(div2_2.className=='close2'){
	    	div1_2.className=(div1_2.className=="close1")?"open1":"close1";
	      	div2_2.className=(div2_2.className=="close2")?"open2":"close2";
	      	var jsonData = {"bookgridCode":codePostfix+"02"};
	     	unlock('operation/bookShelf/unlock',jsonData,'开柜成功',"02");
    	}
    }
    
    var div2_3=document.getElementById("div2_3");
    var div1_3=document.getElementById("div1_3");
    div2_3.onclick=function(){
    	if(div2_3.className=='close2'){
	    	div1_3.className=(div1_3.className=="close1")?"open1":"close1";
	      	div2_3.className=(div2_3.className=="close2")?"open2":"close2";
	      	var jsonData = {"bookgridCode":codePostfix+"03"};
	     	unlock('operation/bookShelf/unlock',jsonData,'开柜成功',"03");
    	}
    }
    
    var div2_4=document.getElementById("div2_4");
    var div1_4=document.getElementById("div1_4");
    div2_4.onclick=function(){
    	if(div2_4.className=='close2'){
	    	div1_4.className=(div1_4.className=="close1")?"open1":"close1";
	      	div2_4.className=(div2_4.className=="close2")?"open2":"close2";
	      	var jsonData = {"bookgridCode":codePostfix+"04"};
	     	unlock('operation/bookShelf/unlock',jsonData,'开柜成功',"04");
    	}
    }
    
    var div2_5=document.getElementById("div2_5");
    var div1_5=document.getElementById("div1_5");
    div2_5.onclick=function(){
    	if(div2_5.className=='close2'){
	    	div1_5.className=(div1_5.className=="close1")?"open1":"close1";
	      	div2_5.className=(div2_5.className=="close2")?"open2":"close2";
	      	var jsonData = {"bookgridCode":codePostfix+"05"};
	     	unlock('operation/bookShelf/unlock',jsonData,'开柜成功',"05");
    	}
    }
    
    var div2_6=document.getElementById("div2_6");
    var div1_6=document.getElementById("div1_6");
    div2_6.onclick=function(){
    	if(div2_6.className=='close2'){
	    	div1_6.className=(div1_6.className=="close1")?"open1":"close1";
	      	div2_6.className=(div2_6.className=="close2")?"open2":"close2";
	      	var jsonData = {"bookgridCode":codePostfix+"06"};
	     	unlock('operation/bookShelf/unlock',jsonData,'开柜成功',"06");
    	}
    }
    
    var div2_7=document.getElementById("div2_7");
    var div1_7=document.getElementById("div1_7");
    div2_7.onclick=function(){
    	if(div2_7.className=='close2'){
	    	div1_7.className=(div1_7.className=="close1")?"open1":"close1";
	      	div2_7.className=(div2_7.className=="close2")?"open2":"close2";
	      	var jsonData = {"bookgridCode":codePostfix+"07"};
	     	unlock('operation/bookShelf/unlock',jsonData,'开柜成功',"07");
    	}
    }
    
    var div2_8=document.getElementById("div2_8");
    var div1_8=document.getElementById("div1_8");
    div2_8.onclick=function(){
    	if(div2_8.className=='close2'){
	    	div1_8.className=(div1_8.className=="close1")?"open1":"close1";
	      	div2_8.className=(div2_8.className=="close2")?"open2":"close2";
	      	var jsonData = {"bookgridCode":codePostfix+"08"};
	     	unlock('operation/bookShelf/unlock',jsonData,'开柜成功',"08");
    	}
    }
}
function unlock(uri, data, message,postfix) {
	$.ajax({
		url : baseURL + uri,
		type : 'POST',
		contentType : "application/json; charset=utf-8",
		data : JSON.stringify(data),
		dataType : 'json',
		success : function(result) {
			if (result.detail != null) {
				layer.msg(result.detail.message, {
					icon : -1
				});
			} else {
				layer.msg(message, {
					icon : -1
				});
			}
			var textHint = document.getElementById('hint');
    		textHint.value=textHint.value+'\n'+postfix+"号柜请求开柜。"
    		textHint.value = textHint.value+'\n'+result.detail.message;
		}
	});
}
</script>
</html>